#ifndef __MSGEVENTID_H_
#define __MSGEVENTID_H_

#define MSG_SERVER_ADDR "127.0.0.1"
#define MSG_SERVER_PORT 27777
#define KEEPALIVESENCOND (20)
#define CONVERT_CAHR_TO_INT(d,c,b,a) ((int)a<<24|(int)b<<16|(int)c<<8|(int)d)

#include <climits>
class CNullClass
{
   public:
     CNullClass(){}
     ~CNullClass(){}
 
};

//定义消息类型
typedef enum eMsgType_t
{
   PUBLISH = 1,     //发布
   SUBSCRIBE = 2,   //订阅
   PUBRESPONSE = 3, //主动获取数据,接收端收到这个类型事件要回复数据
   UNSUBSCRIBE = 4, //取消订阅
   MAX_MSG = 0xffff

}eMsgType;


//定义事件ID
typedef enum eEVENTID_t
{
   KEEPALIVE_EVENT = 1,   
   TEST_EVENT_1 = 2,
   TEST_EVENT_2,
   TEST_EVENT_3,
   TEST_EVENT_4,
   TEST_EVENT_5,
   TEST_EVENT_6,
   MAX_EVENTID = 0xffff
}eEVENTID;

//定义空类回调函数
typedef  void (CNullClass::*CallbackFunc)(char *msg, int msgLen, void *data);

//定义事件元素结构
typedef struct CBEvent_t
{
  CNullClass *thisp;
  CallbackFunc func;
  void *data;

}CBEvent;



//定义通信数据结构体
typedef struct MsgPacket_t
{
   char header[4];  //"HEAD" 
   int len;
   eMsgType msgtype;
   eEVENTID event;
   int reverse; 
   char data[0]; //数据最后两位固定为0xaa55
}MsgPacket;


#define MSG_PACK_LEN sizeof(MsgPacket)






#endif